package health_system.health_system.service;


import health_system.health_system.dto.*;
import health_system.health_system.entity.Moment;
import org.springframework.data.domain.Pageable;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Optional;
import java.util.Set;

public interface MomentService {
    
    /**
     * Create a new moment
     */
    MomentDTO createMoment(MomentCreateDTO createDTO);
    
    /**
     * Update an existing moment
     */
    MomentDTO updateMoment(Long id, MomentUpdateDTO updateDTO);
    
    /**
     * Delete a moment
     */
    void deleteMoment(Long id);
    
    /**
     * Get a moment by ID
     */
    MomentDTO getMomentById(Long id);
    
    /**
     * Get a moment by ID with user's like status
     */
    MomentDTO getMomentWithLikeStatus(Long id, Long currentUserId);
    
    /**
     * Find a moment entity by ID (for internal use)
     */
    Moment getMomentEntityById(Long id);
    
    /**
     * Find a moment entity by ID (optional, for internal use)
     */
    Optional<Moment> findMomentEntityById(Long id);
    
    /**
     * Get all moments by a user
     */
    List<MomentDTO> getAllMomentsByUser(Long userId);
    
    /**
     * Get paginated moments by a user
     */
    PageResponseDTO<MomentDTO> getAllMomentsByUser(Long userId, Pageable pageable);
    
    /**
     * Get moments visible to a user (applying visibility rules)
     */
    List<MomentDTO> getMomentsVisibleToUser(Long viewerId);
    
    /**
     * Get paginated moments visible to a user (applying visibility rules)
     */
    PageResponseDTO<MomentDTO> getMomentsVisibleToUser(Long viewerId, Pageable pageable);
    
    /**
     * Get moments visible to a user with applied like status
     */
    List<MomentDTO> getMomentsVisibleToUserWithLikeStatus(Long viewerId);
    
    /**
     * Get recommended moments for a user's timeline
     */
    PageResponseDTO<MomentDTO> getRecommendedMomentsForUser(Long viewerId, Pageable pageable);
    
    /**
     * Get moments visible to a user created since a specific time
     */
    PageResponseDTO<MomentDTO> getMomentsVisibleToUserSince(Long viewerId, LocalDateTime since, Pageable pageable);
    
    /**
     * Get a user's moments within a date range
     */
    List<MomentDTO> getMomentsByUserAndDateRange(Long userId, LocalDateTime startDate, LocalDateTime endDate);
    
    /**
     * Count moments by a user
     */
    Long countMomentsByUser(Long userId);
    
    /**
     * Search for moments containing a keyword (respecting visibility)
     */
    List<MomentDTO> searchMomentsByKeyword(String keyword, Long viewerId);
    
    /**
     * Get statistics about a user's moments
     */
    MomentStatsDTO getMomentStatsByUser(Long userId);
    
    /**
     * Get a user's activity summary related to moments
     */
    UserMomentActivityDTO getUserMomentActivity(Long userId);
    
    /**
     * Add a user to the visibility list
     */
    void addUserToVisibilityList(Long momentId, Long userId);
    
    /**
     * Remove a user from the visibility list
     */
    void removeUserFromVisibilityList(Long momentId, Long userId);
    
    /**
     * Update the visibility settings of a moment
     */
    MomentDTO updateMomentVisibility(Long id, Moment.VisibilityType visibility, Set<Long> visibleToUserIds);
    
    /**
     * Get top trending moments based on likes, comments, and shares
     */
    List<MomentDTO> getTrendingMoments(Long viewerId, int limit);
    
    /**
     * Get batch of moment details by IDs (for frontend optimization)
     */
    List<MomentDTO> getMomentsByIds(List<Long> momentIds, Long viewerId);
} 